package plugin.eos.awake.flutter.awake1.utils;

import android.graphics.Paint;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.widget.TextView;

import com.binaryfork.spanny.Spanny;

/**
 * 轻微粗体
 */
public class FakeBoldSpan extends CharacterStyle {

	@Override
	public void updateDrawState(TextPaint tp) {
		tp.setFakeBoldText(true);//一种伪粗体效果，比原字体加粗的效果弱一点
		tp.setStyle(Paint.Style.FILL_AND_STROKE);
		// tp.setColor(Color.RED);//字体颜色
		tp.setStrokeWidth(0);//控制字体加粗的程度
	}

	public static void setText(TextView textview, int textId) {
		if (textview != null) {
			textview.setText(new Spanny().append(textview.getContext().getString(textId), new FakeBoldSpan()));
		}
	}

	public static void setText(TextView textview, String text) {
		if (textview != null && !TextUtils.isEmpty(text)) {
			textview.setText(new Spanny().append(text, new FakeBoldSpan()));
		}
	}

	public static Spanny getFakeBoldSpan(String text) {
		return new Spanny().append(text, new FakeBoldSpan());
	}
}